package com.zxl.yjb.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

/**
 * 首页 Viewpager使用的适配器
 * Created by Administrator on 2017/5/25.
 */

public class BottomNavAdapter extends FragmentPagerAdapter {

    private List<Fragment> fragmentsList;
    private String[] bottomNavName;

    public BottomNavAdapter(FragmentManager fm, List<Fragment> fragmentsList, String[] bottomNavName) {
        super(fm);
        this.bottomNavName = bottomNavName;
        this.fragmentsList = fragmentsList;
    }

    @Override
    public Fragment getItem(int position) {
        return fragmentsList.get(position);
    }

    @Override
    public int getCount() {
        return fragmentsList != null ? fragmentsList.size() : 0;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return bottomNavName[position];
    }
}
